package com.hcbd.tdwt.ui.xingyu.vo;

import com.hcbd.tdwt.util.AppDatabase;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.raizlabs.android.dbflow.structure.BaseModel;

import java.io.Serializable;

@Table(database = AppDatabase.class)
public class BDBoxVO extends BaseModel implements Serializable {
    @PrimaryKey(autoincrement = true)
    public int id;
    @Column
    public String bluetoothName;
    @Column
    public String bdCardNum;
    @Column
    public String cardMode;
    @Column
    public String macAdders;

    public static void upData(BDBoxVO boxVO){
        BDBoxVO bdBoxVO= SQLite.select().from(BDBoxVO.class).where(BDBoxVO_Table.macAdders.eq(boxVO.macAdders)).querySingle();
        if(bdBoxVO==null){
            boxVO.insert();
        }else{
            bdBoxVO.bdCardNum=boxVO.bdCardNum;
            bdBoxVO.bluetoothName=boxVO.bluetoothName;
            bdBoxVO.cardMode=boxVO.cardMode;
            bdBoxVO.macAdders=boxVO.macAdders;
            bdBoxVO.update();
        }

    }
}
